package gui.control;

import gui.TDFrame;
import gui.TDprop;

import java.awt.AWTEvent;
import java.awt.Dimension;
import java.awt.BorderLayout;

import javax.swing.JFrame;
import javax.swing.JToggleButton;
import javax.swing.BorderFactory;
import javax.swing.border.BevelBorder;

public class TDControlFrame extends JFrame  implements TDprop{
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	TDFrame tdframe;
	
	
	JToggleButton startStop;
	TDContModus   controlModus;
	TDListPlayer  listPlayer;
	public TDControlFrame(TDFrame tdf)
	{
		super();
		tdframe = tdf;
		this.setUndecorated(true);
		this.rootPane.setBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED));
		this.setVisible(true);
		
		startStop    = new JToggleButton("start");
		controlModus = new TDContModus();
		listPlayer   = new TDListPlayer();
		
		this.getRootPane().setLayout(new BorderLayout(10,10));
		this.getRootPane().add(controlModus, BorderLayout.NORTH);
		this.getRootPane().add(listPlayer, BorderLayout.CENTER);
		this.getRootPane().add(startStop, BorderLayout.SOUTH);
		this.enableEvents(AWTEvent.FOCUS_EVENT_MASK);
	}
	
	public void center(Dimension d)
	{
		//double width
		this.setSize((int)(tdframe.realWidth/4),(int) tdframe.realHeight - tdframe.getHeight() - tdframe.border);	
		double xp = d.width*(1- tdframe.propx)/2;
		double yp = d.height*(1- tdframe.propy)/2;
		
		this.setLocation((int)xp + 3*tdframe.getWidth()/4, (int)yp+ tdframe.getHeight() + tdframe.border);
		//TODO
	}

	protected void processEvent(AWTEvent e)
	{
	//	if(e.getID() == FocusEvent.FOCUS_GAINED)
	//		tdframe.showAll();
		super.processEvent(e);
	}
}
